/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fl.location.conn;

import java.io.IOException;
import java.io.InputStream;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.lcdui.Image;

/**
 *
 * @author Zeor
 */
public class HttpConnector {

    String IP = "http://maps.google.com/staticmap?maptype=roadmap?";
    String conf = "center=55.681308,12.576325&zoom=14&size=600x600&markers=55.681308,12.576325,redg&markers=55.671308,12.576325,greeng&key=ABQIAAAAq-Qz8TGIOsr6uFju08iHzxT5lTfaIV3_uH6bju3oJBbGgtb9qxTntKMOIi3VeneWnsfCit-ZallR3A";

    String center = "center=55.681308,12.576325"; //Enum med bynavn kontra koordinater ville være perf
    String zoom = "zoom=14";
    String imageSize = "&size=600x600";
    String[] markers; //Egen hentes vha lokations API'et (rød), andres hentes fra server. (grøn)
    
    public HttpConnector() {

    }

    public Image getImage() {
        try {
            HttpConnection httpCon = null;
            InputStream is = null;
            /// Opening Http Connection
            httpCon = (HttpConnection) Connector.open(url, Connector.READ, false);
//            int byteLength = (int)httpCon.getLength();
            is = httpCon.openInputStream();
            Image data = Image.createImage(is);
            is.close();
            httpCon.close();
            return data;
            
        /**
        read return data from server
         */
        } catch (IOException ex) {
            System.out.println("IOException");
            ex.printStackTrace();
        } catch (SecurityException sex) {
            System.out.println("Security Exception");
            sex.printStackTrace();
        } catch (Exception ex) {
            ex.printStackTrace();
        } catch (OutOfMemoryError oomer) {
            System.out.println("Out OF Memory Exception");
            oomer.printStackTrace();

        } finally {
            return null;
        }
    }
}
